package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResPicture;
import com.hmkj.entity.ErspResReview;

public class ErspResReviewDao extends JActiveTable {

	public ErspResReviewDao() {
		this.setDBTableName("ersp_res_review");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", String.valueOf(Sequence.getGuid()));

		
		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("req_id", "req_id", ActiveField.ftString, 36));
		AddField(new JActiveField("review_star", "review_star", ActiveField.ftInteger));
		AddField(new JActiveField("review_title", "review_title", ActiveField.ftString, 110));
		AddField(new JActiveField("review_content", "review_content", ActiveField.ftString, 500));
		AddField(new JActiveField("user_id", "user_id", ActiveField.ftString, 36));
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));

		setDbKeyFields("id");
	}
	public int add(ErspResReview vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("req_id", vo.getReq_id());
		setFieldValue("review_star", vo.getReview_star());
		setFieldValue("review_title", vo.getReview_title());
		setFieldValue("review_content", vo.getReview_content());
		setFieldValue("user_id", vo.getUser_id());
		return DBManager.ExecSQL(this.getSQL());
	}

	
	public String getSQL(ErspResReview vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("req_id", vo.getReq_id());
		setFieldValue("review_star", vo.getReview_star());
		setFieldValue("review_title", vo.getReview_title());
		setFieldValue("review_content", vo.getReview_content());
		setFieldValue("user_id", vo.getUser_id());
		return this.getSQL();
	}
	
}